<!-- 头部 -->
<include file="Public:header" />

        <!-- header-section end-->
        <div class="index-wrapper" style="padding-bottom: 0px;">
            <form class="layui-form" method="post">
            <div class="banner-section" style="height: 100%;padding: 20px;background: #fff;">
                <div style="width: 90%;height: 130px;border-radius: 8px;">
                    <img id="LAY_demo_upload" src="__PUBLIC__/home/images/xm.png" alt="" style="width: 90%;height: 130px;position: absolute;">
                    <div style="position: relative;padding-top: 20px;padding-left: 30%;">
                        <div style="width: 50px;height: 50px;border: 1px solid #fff;border-radius: 20px;margin-left: 40px;">
                            <span style="font-size: 30px;position: relative;left: 15px;top: 8px;color:#D2D2D2;">+</span>
                        </div>
                        <div class="site-demo-upbar" style="position: absolute;top: 15px;opacity: 0;">
                            <input type="file" name="file" class="layui-upload-file" id="xmimg">
                        </div>
                        <p style="padding-top: 10px;padding-left: 22px;font-size: 8px;color:#fff;">添加项目背景图</p>
                    </div>
                </div>
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span>标题:</span>
                <input type="text" name="xm_name" lay-verify="xm_name" placeholder="例：为山区小孩上梦想课" style="border: 0px;background: #F1F2F7;width: 80%;height: 25px;border-radius: 15px;" value="{$res_info.sfzname}">
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span style="display: block;width: 35px;float: left;">摘要:</span>
                <textarea name="xm_content" lay-verify="xm_content" cols="25" rows="4" style="width: 80%;border: 0px;background: #F1F2F7;border-radius: 8px;" placeholder="例：为山区捐款捐物">{$res_info.xm_content}</textarea>
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span>类型:</span>
                <input type="text" name="xm_type" lay-verify="xm_type" placeholder="例：教育助学" style="border: 0px;background: #F1F2F7;width: 80%;height: 25px;border-radius: 15px;" value="{$res_info.xm_type}">
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span>地域:</span>
                <input type="text" name="xm_diyu" lay-verify="xm_diyu" placeholder="例：广东贫困山区" style="border: 0px;background: #F1F2F7;width: 80%;height: 25px;border-radius: 15px;" value="{$res_info.xm_diyu}">
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span style="display: block;width: 35px;float: left;">详情:</span>
                <textarea name="xm_xiangq" lay-verify="xm_xiangq" cols="25" rows="4" style="width: 80%;border: 0px;background: #F1F2F7;border-radius: 8px;" placeholder="用朴实的语言描述你或他们的故事">{$res_info.xm_xiangq}</textarea>
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span>天数:</span>
                <input type="text" name="xm_days" lay-verify="xm_days" placeholder="范围1-99天" style="border: 0px;background: #F1F2F7;width: 80%;height: 25px;border-radius: 15px;" value="{$res_info.xm_days}">
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span>目标:</span>
                <input type="text" name="xm_mubiao" lay-verify="xm_mubiao" placeholder="例：10000/本" style="border: 0px;background: #F1F2F7;width: 80%;height: 25px;border-radius: 15px;" value="{$res_info.xm_mubiao}">
            </div>
            <div class="product-list" style="padding: 10px 20px;margin: 0px;background: #fff;">
                <span style="display: block;width: 35px;float: left;">清单:</span>
                <textarea name="xm_list" lay-verify="xm_list" cols="25" rows="4" style="width: 80%;border: 0px;background: #F1F2F7;border-radius: 8px;" placeholder="写出筹集所需物品名单">{$res_info.xm_list}</textarea>
            </div>
            <input type="hidden" name="xm_img" id="xm_img" value="">
            <input type="hidden" name="rztype" value="{$rztype}">
            <button lay-submit="" lay-filter="*" style="background-color: #FF921D;color: #fff;width: 100%;height: 46px;border:0px;">提交审核</button>
        </form>  
        </div>
<script type="text/javascript">
    layui.use(['form','layer','upload'], function(){
       $ = layui.jquery;
      var layer = layui.layer
      ,form = layui.form();
      //layer.msg('Hello World');
    //自定义验证规则
    form.verify({
      xm_name: function(value){
        if(value.length < 1){
          return '请输入标题';
        }
      }
      ,xm_content: function(value){
        if(value.length < 1){
          return '请输入摘要';
        }
      }
      ,xm_type: function(value){
        if(value.length < 1){
          return '请输入类型';
        }
      }
      ,xm_diyu: function(value){
        if(value.length < 1){
          return '请输入地域';
        }
      }
      ,xm_xiangq: function(value){
        if(value.length < 1){
          return '请输入详情';
        }
      }
      ,xm_days: function(value){
        if(value.length < 1){
          return '请输入天数';
        }
      }
      ,xm_mubiao: function(value){
        if(value.length < 1){
          return '请输入目标';
        }
      }
      ,xm_list: function(value){
        if(value.length < 1){
          return '请输入清单';
        }
      }
    });
    
    layui.upload({
        url: '{:U("setup/xmimg")}' //上传接口
        ,elem: '#xmimg' //指定原始元素，默认直接查找class="layui-upload-file"
        ,success: function(res){ //上传成功后的回调
          //console.log(res)
          //location.reload();
          LAY_demo_upload.src = res.data.src;
          xm_img.value = res.data.path;
        }
    });

      //交互
    form.on('submit(*)', function(data){
        $.ajax({
            url: "{:U('setup/chuangj')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});
                  }else{
                     layer.msg(response.info ,{icon:6});
                     //location.reload();
                     location.href = response.url;
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });   

    });


</script>

    </body>
</html>